// pages/index/business/rent/index.js
import {getZzLists} from "../../../../utils/api/module/task.js"
Page({
    data: {
        jpzzList: [],
        page: 1,
        isLineData: 0
    },
    onLoad: function (options) {
        this.getData()
    },
    getData: function() {
        getZzLists({
            page: this.data.page,
            limit: 10,
            renttype: '',
            space: '',
            price: '',
            decorate: '',
            area: '',
            subway: ''
        }).then(res => {
            if(res.data.data) {
                this.setData({
                    ['jpzzList[' + (this.data.page - 1) +']']: res.data.data.rows,
                    isLineData: this.data.page !== 1 && res.data.data.rows.length > 10 ? 2 : (this.data.page == 1 && res.data.data.rows.length == 10 ? 1 : 0)
                 });
                 return false;
            };
            this.setData({
                ['jpzzList[' + (this.data.page - 1) +']']: [],
                isLineData: 0
            });
        })
    },
    onReachBottom: function() {
        if(this.data.jpzzList[this.data.page - 1].length == 10) {
            this.data.page += 1;
            this.setData({
                isLineData: 1
            });
            setTimeout(() => {
                this.getData();
            }, 1500);
            
        }else{
            this.setData({
                isLineData: 2
            });
        };
    }
})